from datetime import date

from numpy import integer
from pydantic import BaseModel, Field
from typing import Literal

'''
定义请求模型和响应模型的类,用pydantic定义
'''


class Student(BaseModel):
    # 学生编号9位，前6位是学生班级，作为主键
    student_id: int = Field(None, description="系统自动生成")

    # 学生班级，与学生编号前6位对应
    class_id: str = Field(..., min_length=6, max_length=6, description="学生班级编号(6位)")

    # 学生姓名，非空且合理长度
    student_name: str = Field(..., min_length=1, max_length=50, description="学生姓名")

    # 籍贯，非空且合理长度
    native_place: str = Field(..., min_length=1, max_length=100, description="学生籍贯")

    # 毕业院校，非空且合理长度
    graduate_school: str = Field(..., min_length=1, max_length=100, description="毕业院校")

    # 专业，非空且合理长度
    major: str = Field(..., min_length=1, max_length=50, description="专业")

    # 入学时间，date类型
    enrollment_date: date = Field(..., description="入学时间(年月日)")

    # 毕业时间，date类型
    graduation_date: date = Field(..., description="毕业时间(年月日)")

    # 学历，限定为本科、专科、硕士、博士
    education: Literal["本科", "专科", "硕士", "博士"] = Field(..., description="学历")

    # 顾问编号，合理长度
    advisor_id: str = Field(..., min_length=1, max_length=20, description="顾问编号")

    # 年龄在0-100之间
    age: int = Field(..., ge=0, le=100, description="年龄(0-100之间)")

    # 性别，限定为男或女
    gender: Literal["男", "女"] = Field(..., description="性别(男/女)")


class Stu_score(BaseModel):
    # 学生编号9位，前6位是学生班级，作为外键
    student_id: int

    # 考核序次 记录第几次考试
    round: int

    # 分数,只有0-100分
    score: int = Field(..., ge=0, le=100)


class Stu_employment(BaseModel):
    student_id: int = Field(..., description="外键")

    # 就业开放时间采用日期类
    open_time: date = Field(..., description="就业开放时间")

    # offer下放时间
    offer_time: date = Field(..., description="就业开放时间")

    # 公司名字
    company: str = Field(..., min_length=1, max_length=50, description="公司名")

    # 就业薪资
    salary: int = Field(..., gt=0, description="就业薪资")


# 班级类
class stu_class(BaseModel):
    class_id: str = Field(..., min_length=6, max_length=6, description="班级编号(6位)")

    class_name: str = Field(..., min_length=1, max_length=50, description="班级名称")
